package com.xbongbong.saas.script.tempenum;

import com.xbongbong.paas.field.FieldAttrEntity;
import com.xbongbong.pro.enums.AmountFlagEnum;
import com.xbongbong.paas.field.SaasParticularAttributePoJo;
import com.xbongbong.saas.enums.PayBalanceEnum;
import com.xbongbong.saas.enums.XbbRefTypeEnum;
import lombok.Getter;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @author 徐俊杰
 * @date 2020/2/24 9:27
 * @since v1.0
 */
@Getter
public enum TempPrepayBalanceEnum {
    ADVANCE_PAY_BALANCE(PayBalanceEnum.ADVANCE_PAY_BALANCE),
    SUPPLIER_ID(PayBalanceEnum.SUPPLIER_ID),
    SUPPLIER_NAME(PayBalanceEnum.SUPPLIER_NAME),
    PURCHASE_COUNT(PayBalanceEnum.PURCHASE_COUNT),
    OWNER_ID(PayBalanceEnum.OWNER_ID),
    CREATOR_ID(PayBalanceEnum.CREATOR_ID),
    ADD_TIME(PayBalanceEnum.ADD_TIME),
    UPDATE_TIME(PayBalanceEnum.UPDATE_TIME),
    ;

    private PayBalanceEnum anEnum;

    TempPrepayBalanceEnum(PayBalanceEnum anEnum) {
        this.anEnum = anEnum;
    }

    public static List<TempPrepayBalanceEnum> getAllEnum() {
        List<TempPrepayBalanceEnum> list = new ArrayList<>();
        Collections.addAll(list, values());
        return list;
    }

    public static void initPurchaseCount(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setDisableListSort(1);
    }

    public static void initSupplierId(FieldAttrEntity fieldAttrEntity) {
        //特殊处理，只有导出用到，不置成客户的100,防止被解析成子表单
        //不能使用RedundantTemplateTypeEnum内的预收款余额PREPAYMENT_BALANCE，因为其会转为回款单的预收款类型
        fieldAttrEntity.setLinkedType(XbbRefTypeEnum.PREPAY_BALANCE.getCode());
        fieldAttrEntity.setLinkedText(SUPPLIER_NAME.getAnEnum().getAttr());
        SaasParticularAttributePoJo saasParticularAttributePoJo = new SaasParticularAttributePoJo();
        saasParticularAttributePoJo.setMultiCheck(false);
        fieldAttrEntity.setSaasParticularAttributePoJo(saasParticularAttributePoJo);
        fieldAttrEntity.setIsForbidden(0);
        fieldAttrEntity.setDisableListSort(1);
    }
    public static void initAdvancePayBalance(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setSummaryFlag(1);
        fieldAttrEntity.setAmountFlag(AmountFlagEnum.YES.getType());
        fieldAttrEntity.setIsForbidden(0);
    }
}
